<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/resources/template/template.xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <h:form>    
            <p:panel header="Manage Rosters" >
                <h:panelGrid id ="gpVeda" columns="2" styleClass="alignTop" >
                    <h:panelGrid id="gpSelect" columns="1"  >
                        <p:panel >
                            <h:panelGrid id="gpSelectText" >
                                <p:selectOneListbox converter="rosterCon"  id="lstSelect"  
                                                    value="#{rosterController.current}" 
                                                    style="min-width: 223px;height: 300px;">
                                    <f:selectItems  value="#{rosterController.items}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                    <f:ajax render="gpDetail" execute="lstSelect" >
                                    </f:ajax>
                                </p:selectOneListbox>
                            </h:panelGrid>
                            <h:panelGrid id="gpSelectButtons" columns="3"  >

                                <p:commandButton id="btnAdd" ajax="false" value="Add" action="#{rosterController.prepareAdd()}" styleClass="buttons" onclick="onSubmitButton();" >
                                </p:commandButton>

                                <p:commandButton id="btnDelete" ajax="false" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                            return false;" action="#{rosterController.delete()}"  value="Delete"  >
                                </p:commandButton>

                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid  >

                    <p:panel>
                        <h:panelGrid id="gpDetail" columns="1">
                            <h:panelGrid id="gpDetailText" columns="2">
                                <h:outputText  value="Name" ></h:outputText>
                                <p:inputText autocomplete="off"  value="#{rosterController.current.name}"  />
                                <h:outputText  value="Department" ></h:outputText>
                                <p:selectOneMenu value="#{rosterController.current.department}">
                                    <f:selectItem itemLabel="Select Department"/>
                                    <f:selectItems value="#{departmentController.logedDepartments}" var="d" itemLabel="#{d.name}" itemValue="#{d}"/>
                                </p:selectOneMenu>
                                <p:outputLabel value="Start Time" rendered="false"/>                        
                                <p:calendar rendered="false" value="#{rosterController.current.startingTime}" navigator="true" pattern="HH:mm:ss" timeOnly="true">                            
                                </p:calendar>    
                                <h:outputLabel value="Shifts Per One Person Per Day"/>  
                                <p:inputText autocomplete="off" value="#{rosterController.current.shiftPerDay}"/>
                            </h:panelGrid>
                            <h:panelGrid id="gpDetailButtons" columns="2">
                                <p:commandButton id="btnSave" ajax="false" value="Save" action="#{rosterController.saveSelected()}" styleClass="buttons" onclick="onSubmitButton();">
                                </p:commandButton>
                                <p:defaultCommand target="btnSave"/>
                            </h:panelGrid>
                        </h:panelGrid>
                    </p:panel>
                </h:panelGrid>
            </p:panel>


        </h:form>
    </ui:define>

</ui:composition>
